﻿Imports Entidades.ELocalidad
Imports System.Data.SqlClient
Public Class Dcliente

    Inherits conexion
    Dim cmd As New SqlCommand
    Public Function insertarcliente(ByVal dts As Entidades.Ecliente) As Boolean
        Try
            conectado()
            cmd = New SqlCommand("insertar_cliente")
            cmd.CommandType = CommandType.StoredProcedure
            cmd.Connection = cnn
            cmd.Parameters.AddWithValue("@legcli", dts.legcli)
            cmd.Parameters.AddWithValue("@dni", dts.dnipers)
            cmd.Parameters.AddWithValue("@nombre", dts.nompers)
            cmd.Parameters.AddWithValue("@apellido", dts.apepers)
            cmd.Parameters.AddWithValue("@fecha_nac", dts.fecha_nacpers)
            cmd.Parameters.AddWithValue("@dom", dts.dompers)
            cmd.Parameters.AddWithValue("@tel", dts.telpers)
            cmd.Parameters.AddWithValue("@rec_sueldo", dts.sueldocli)
            cmd.Parameters.AddWithValue("@grupo_familiar", dts.familiacli)
            cmd.Parameters.AddWithValue("@loca", dts.localpers)

            If cmd.ExecuteNonQuery Then
                Return True
            Else
                Return False
            End If

        Catch ex As Exception
            MsgBox(ex.Message)
            Return False
        Finally
            desconectado()
        End Try
    End Function

    Public Function llenarcombo() As DataTable
        Try
            conectado()
            cmd = New SqlCommand("llenarcombolocalidad")
            cmd.CommandType = CommandType.StoredProcedure
            cmd.Connection = cnn

            Dim DA As New SqlDataAdapter(cmd)
            Dim TABLA As New DataTable
            TABLA.Clear()
            DA.Fill(TABLA)
            Return TABLA
            Return Nothing
        Catch ex As Exception
            MsgBox(ex.Message)
            Return Nothing
        Finally
            desconectado()
        End Try
    End Function


End Class

